package com.sky.controller.user;

import com.sky.constant.RedisKeyConstant;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/shop")
@Api(value ="用户端店铺状态")
@Slf4j
public class UserShopController {
    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("/status")
    @ApiOperation(value = "用户获取店铺状态")
    public Result getShopStatus() {
        Integer o = (Integer)redisTemplate.opsForValue().get(RedisKeyConstant.SHOP_STATUS_KEY);
        log.info("获取到店铺的营业状态为：{}",o == 1 ? "营业中" : "打烊中");
        return Result.success(o);
    }
}
